﻿namespace Picnic.Web.FastCGI
{
    /// <summary>
    /// Represents a unit FastCGI protocol.
    /// </summary>
    public class FastCGIRecord
    {
        private readonly int _version;
        private readonly FastCGIRecordType _recordType;
        private readonly int _requestId;
        private readonly int _contentLength;
        private readonly byte[] _content;

        /// <summary>
        /// Initialiez a new instance of FastCGIRecord class.
        /// </summary>
        public FastCGIRecord(int version, FastCGIRecordType recordType, int requestId, int contentLength, byte[] content)
        {
            _version = version;
            _recordType = recordType;
            _requestId = requestId;
            _contentLength = contentLength;
            _content = content;
        }

        /// <summary>
        /// Gets a protocol version.
        /// </summary>
        public int Version
        {
            get { return _version; }
        }

        /// <summary>
        /// Gets a recorf type.
        /// </summary>
        public FastCGIRecordType RecordType
        {
            get { return _recordType; }
        }

        /// <summary>
        /// Gets request identifier.
        /// </summary>
        public int RequestId
        {
            get { return _requestId; }
        }

        /// <summary>
        /// Gets a content length.
        /// </summary>
        public int ContentLength
        {
            get { return _contentLength; }
        }

        /// <summary>
        /// Gets this record content.
        /// </summary>
        public byte[] Content
        {
            get { return _content; }
        }
    }
}
